// pages/classHomePage/signIn/signMessage/signMessage.js
// pages/teacherfunction/signin/signmessage/signmessage.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    signList: [],
    flag: 0,
    people: null,
    sign_in_title: null,
    teacher_sign_in_id: null,
    is_signed_list: [],
    not_signed_list: [],
    signed_state: null,
    signed_num: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let _this = this
    if (options != null) {
      console.log('页面跳转传值：', options)
      _this.setData({
        sign_in_title: options['sign_in_title'],
        teacher_sign_in_id: options['teacher_sign_in_id'],
        people: wx.getStorageSync("people"),
        signed_state: options['state']
      })
      _this.get_sign_in_detail()
    }

  },

  flag0: function () {
    this.setData({
      flag: 0
    })
  },

  flag1: function () {
    this.setData({
      flag: 1
    })
  },

  teacherCloseSignIn: function () {
    let _this = this
    if (wx.getStorageSync("people") == 'teacher') {
      app.formGet('/close_qiandao_by_title?code=' + String(wx.getStorageSync("myCode")) + '&sign_in_title=' + _this.data.sign_in_title + '&teacher_account=' + String(wx.getStorageSync("account"))).then(res => {
        if (res['code'] == 1) {
          console.log('老师关闭签到成功');
          wx.navigateBack()
        }
      })
    }
  },

  get_sign_in_detail: function () {
    let _this = this
    app.formGet('/get_sign_in_detail?course_name=' + String(app.globalData.banji_info['courseName']) + '&teacher_sign_in_id=' + String(_this.data.teacher_sign_in_id)).then(res => {
      console.log('获取班级学生签到情况：', res);
      _this.setData({
        is_signed_list: res[0],
        not_signed_list: res[1],
        signed_num: [Object.keys(res[0]).length, Object.keys(res[1]).length],
      })
    })
  },

  onReady() {

  },

  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})